import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', () => {
  // 定义的状态 state
  const token = ref<string>('')
  const userinfo = ref<{
    avatar: string,
    gender: number,
    id: number
    nickname: string
    username: string
  } | {}>({})

  // 定义的actions
  function settoken(data: string) {
    token.value = data
  }

  function setuserinfo(data: any) {
    userinfo.value = data
  }

  return { token, userinfo, settoken, setuserinfo }
})
